<?php
session_start();
//ini_set('display_errors',1);
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.site.php');
ob_start("sanitize_output");
$term=strtolower($_POST['post']);
$dictionary_link = pspell_new("en", "british");
$check=pspell_check($dictionary_link, $term);
$org=metaphone($term);
if(!$check) {
$suggestions = pspell_suggest($dictionary_link, $term);
//print_r($suggestions);
	echo('<ul>');
	foreach($suggestions as $row) {
		if($i<10) {
			$t=metaphone($row);
			
			if($org<>$t) {
				echo('<li> <a href="#" class="sug-res" rel="'.$row.'">'.$row.'</a></li>');
			}
		$i++;
		}
		
	}
	echo('</ul>');
}
?>